package com.example.club.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.club.R
import com.example.club.model.TeamCard

class TeamCardAdapter(private val data: List<TeamCard>) : RecyclerView.Adapter<TeamCardAdapter.TeamViewHolder>() {
    class TeamViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val iv: ImageView = itemView.findViewById(R.id.iv_team)
        val title: TextView = itemView.findViewById(R.id.tv_team_title)
        val date: TextView = itemView.findViewById(R.id.tv_team_date)
        val count: TextView = itemView.findViewById(R.id.tv_team_count)
    }
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TeamViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_recommend_team, parent, false)
        return TeamViewHolder(view)
    }
    override fun onBindViewHolder(holder: TeamViewHolder, position: Int) {
        val item = data[position]
        holder.iv.setImageResource(item.imageRes)
        holder.title.text = item.title
        holder.date.text = item.date
        holder.count.text = item.count
    }
    override fun getItemCount() = data.size
} 